package org.easy.tool.controller;

import org.easy.tool.common.R;
import org.easy.tool.service.IUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedHashMap;

/**
 * 用户
 *
 * @author Valley
 * @since 2024-09-08 10:19:41
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    IUser userService;

    @RequestMapping("ssoLogin")
    public R ssoLogin(@RequestBody(required = false)LinkedHashMap data) throws Exception {
        return R.ok(userService.ssoLogin(data));
    }

    @RequestMapping("login")
    public R login(@RequestBody(required = false) LinkedHashMap data) throws Exception {
        return R.ok(userService.login(data));
    }

    @RequestMapping("isLogin")
    public R isLogin(@RequestBody(required = false) LinkedHashMap data) throws Exception {
        boolean status = userService.isLogin(data);
        return R.ok(status);
    }

    @RequestMapping("isAdminUser")
    public R isAdminUser(@RequestBody(required = false) LinkedHashMap data) throws Exception {
        boolean isAdminUser = userService.isAdminUser(data);
        return R.ok(isAdminUser);
    }

    @RequestMapping("getUserDetail")
    public R getUserDetail(@RequestBody(required = false)LinkedHashMap data) throws Exception {
        return R.ok(userService.getUserDetail(data));
    }

    @RequestMapping("updateUserDetail")
    public R updateUserDetail(@RequestBody(required = false)LinkedHashMap data) throws Exception {
        return R.ok(userService.updateUserDetail(data));
    }

}
